package com.roger.mybatisplus.demo.service;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UsersService {
    @Autowired
    private DefaultWebSecurityManager securityManager;

    public void userLogin(String username, String password) throws UnknownAccountException{
        SecurityUtils.setSecurityManager(securityManager);

        Subject subject = SecurityUtils.getSubject();

        UsernamePasswordToken token = new UsernamePasswordToken(username, password);

        subject.login(token);
    }

    private static boolean lock = false;

    public static void main(String[] args) {

        System.out.println("before");

        lock = false;

        System.out.println("after");



    }

}
